home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ für Kids
/
C++ for kids.iso
/
Buch
/
Rund2b.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1998-12-30
|
2KB
|
74 lines
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Rund2b.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
const int FMax = 16;
TColor Farbe[FMax] =
{clBlack, clMaroon, clGreen, clNavy, clTeal, clPurple,
clOlive, clGray, clSilver, clRed, clLime, clBlue,
clAqua, clFuchsia, clYellow, clWhite};
TKreis *Kreis;
TForm1 *Form1;
//---------------------------------------------------------------------------
TKreis::TKreis(int xx, int yy, int dd)
{
x = xx; y = yy; Dicke = dd;
}
//---------------------------------------------------------------------------
void TKreis::Erscheinen (void)
{
Form1->Canvas->Brush->Color = Farbe[random (FMax)];
Form1->Canvas->Ellipse (x, y, x+Dicke, y+Dicke);
}
//---------------------------------------------------------------------------
void TKreis::Bewegen (void)
{
TRect Quelle, Ziel;
for (int i=x-5; i<Form1->ClientWidth-Dicke-x-5; i++)
{
Quelle = Rect(i, y-5, i+Dicke+5, y+Dicke+5);
Ziel = Rect(i+1, y-5, i+Dicke+6, y+Dicke+5);
Form1->Canvas->CopyRect(Ziel, Form1->Canvas, Quelle);
// Bremse, abhΣngig vom Prozessortakt!
for (int j=0; j<1000000; j++) ;
}
}
//---------------------------------------------------------------------------
void TKreis::Verschwinden (void)
{
Form1->Refresh ();
}
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Kreis->Erscheinen ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Kreis->Bewegen ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Kreis->Verschwinden ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
randomize ();
Color = Farbe[random (16)];
Kreis = new TKreis (30, 30, 150);
}
//---------------------------------------------------------------------------